/**
 * Copyright &copy; 2012-2015 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.zouqone.smc.modules.sys.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import com.zouqone.smc.common.persistence.Page;
import com.zouqone.smc.common.service.CrudService;
import com.zouqone.smc.modules.sys.entity.Dictitem;
import com.zouqone.smc.modules.sys.dao.DictitemDao;

/**
 * 字典项管理Service
 * @author zouqh
 * @version 2015-05-26
 */
@Service
@Transactional(readOnly = true)
public class DictitemService extends CrudService<DictitemDao, Dictitem> {

	public Dictitem get(String id) {
		return super.get(id);
	}
	
	public Dictitem getDictitemByCode(String code){
		Dictitem dictitem = new Dictitem();
		dictitem.setCode(code);
		return dao.getDictitemByCode(dictitem);
	}
	
	public List<Dictitem> findList(Dictitem dictitem) {
		return super.findList(dictitem);
	}
	
	public Page<Dictitem> findPage(Page<Dictitem> page, Dictitem dictitem) {
		return super.findPage(page, dictitem);
	}
	
	@Transactional(readOnly = false)
	public void save(Dictitem dictitem) {
		super.save(dictitem);
	}
	
	@Transactional(readOnly = false)
	public void delete(Dictitem dictitem) {
		super.delete(dictitem);
	}
	
	@Transactional(readOnly = false)
	public void delete(String ids) {
		if(!StringUtils.isEmpty(ids)){
			String [] idArray = ids.split(",");
			for (String id : idArray) {
				Dictitem dictitem = super.get(id);
				super.delete(dictitem);
			}
		}
	} 
	
}